﻿// <copyright file="IUriReference.cs" company="Alan Dean">
// The MIT License

// Copyright (c) 2008 Alan Dean

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// </copyright>
// <author>Alan Dean</author>
// <email>alan.dean@thoughtpad.net</email>

namespace Semantic.Rdf
{
    using System;

    /// <summary>Defines the RDF URI reference interface.</summary>
    /// 
    /// <remarks>
    /// A URI reference within an RDF graph (an RDF URI reference) is a Unicode string.
    /// </remarks>
    /// 
    /// <seealso href="http://www.w3.org/TR/rdf-concepts/#section-URI-Vocabulary">
    /// URI-based Vocabulary and Node Identification
    /// </seealso>
    public interface IUriReference
    {
        #region bool IsBlankNode
        /// <summary>
        /// Gets a value indicating whether this instance is a blank node.
        /// </summary>
        /// 
        /// <remarks>
        /// <para>
        /// The blank nodes in an RDF graph are drawn from an infinite set.
        /// This set of blank nodes, the set of all
        /// <see href="http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference">RDF URI references</see>
        /// and the set of all <see href="http://www.w3.org/TR/rdf-concepts/#dfn-literal">literals</see> are pairwise disjoint.
        /// </para>
        /// <para>Otherwise, this set of blank nodes is arbitrary.</para>
        /// <para>
        /// RDF makes no reference to any internal structure of blank nodes.
        /// Given two blank nodes, it is possible to determine whether or not they are the same.
        /// </para>
        /// </remarks>
        /// 
        /// <seealso href="http://www.w3.org/TR/rdf-concepts/#section-blank-nodes">Blank Nodes</seealso>
        bool IsBlankNode
        {
            get;
        }
        #endregion

        #region string LexicalForm
        /// <summary>
        /// Gets the <see href="http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference">URI reference</see> lexical form.
        /// </summary>
        /// 
        /// <value>
        /// A <see href="http://www.w3.org/TR/rdf-concepts/#ref-unicode">Unicode</see>
        /// <see langword="string"/> that:
        /// <list type="bullet">
        /// <item>does not contain any control characters ( #x00 - #x1F, #x7F-#x9F)</item>
        /// <item>
        /// and would produce a valid URI character sequence (per RFC2396 <see href="http://www.w3.org/TR/rdf-concepts/#ref-uris">URI</see>, sections 2.1)
        /// representing an absolute URI with optional fragment identifier when subjected to the encoding described below.
        /// </item>
        /// </list>
        /// </value>
        /// 
        /// <remarks>
        /// The encoding consists of:
        /// <list type="number">
        /// <item>
        /// encoding the Unicode string as UTF-8 <see href="http://www.w3.org/TR/rdf-concepts/#ref-rfc-2279">RFC-2279</see>, giving a sequence of octet values.
        /// </item>
        /// <item>%-escaping octets that do not correspond to permitted US-ASCII characters.</item>
        /// </list>
        /// <para>
        /// The disallowed octets that must be %-escaped include all those that do not correspond to US-ASCII characters,
        /// and the excluded characters listed in Section 2.4 of <see href="http://www.w3.org/TR/rdf-concepts/#ref-uris">URI</see>,
        /// except for the number sign (#), percent sign (%), and the square bracket characters re-allowed in
        /// <see href="http://www.w3.org/TR/rdf-concepts/#ref-rfc-2732">RFC-2732</see>.
        /// </para>
        /// <para>
        /// Disallowed octets must be escaped with the URI escaping mechanism
        /// (that is, converted to %HH, where HH is the 2-digit hexadecimal numeral corresponding to the octet value).
        /// </para>
        /// <para>
        /// Two RDF URI references are equal if and only if they compare as equal, character by character, as Unicode strings.
        /// </para>
        /// <para>
        /// <strong>Note:</strong>
        /// RDF URI references are compatible with the <see href="http://www.w3.org/TR/xmlschema-2/#anyURI">anyURI</see> datatype as defined by
        /// XML schema datatypes <see href="http://www.w3.org/TR/rdf-concepts/#ref-xml-schema2">XML-SCHEMA2</see>,
        /// constrained to be an absolute rather than a relative URI reference.
        /// </para>
        /// <para>
        /// <strong>Note:</strong>
        /// RDF URI references are compatible with
        /// <see href="http://www.w3.org/TR/2003/PR-xml-names11-20031105/#IRIs">International Resource Identifiers</see>
        /// as defined by <see href="http://www.w3.org/TR/rdf-concepts/#ref-xml-names11">XML Namespaces 1.1</see>.
        /// </para>
        /// <para>
        /// <strong>Note:</strong>
        /// this section anticipates an RFC on Internationalized Resource Identifiers.
        /// Implementations may issue warnings concerning the use of RDF URI References that do not conform with
        /// <see href="http://www.w3.org/TR/rdf-concepts/#ref-iri">IRI draft</see> or its successors.
        /// </para>
        /// <para>
        /// <strong>Note:</strong>
        /// The restriction to absolute URI references is found in this abstract syntax.
        /// When there is a well-defined base URI, concrete syntaxes, such as RDF/XML,
        /// may permit relative URIs as a shorthand for such absolute URI references.
        /// </para>
        /// <para>
        /// <strong>Note:</strong>
        /// Because of the risk of confusion between RDF URI references that would be equivalent if derefenced,
        /// the use of %-escaped characters in RDF URI references is strongly discouraged.
        /// See also the <see href="http://www.w3.org/2001/tag/issues.html#URIEquivalence-15">URI equivalence issue</see>
        /// of the Technical Architecture Group <see href="http://www.w3.org/TR/rdf-concepts/#ref-TAG">TAG</see>.
        /// </para>
        /// </remarks>
        string LexicalForm
        {
            get;
        }
        #endregion
    }
}